using UnityEngine;
using Unity.VisualScripting;
using LS.UI;

namespace LS.VisualScripting
{
    public class CloseUIForm : UIUnit
    {
        [DoNotSerialize]
        [PortLabelHidden]
        public ValueInput UIFormId { get; set; }
        
        protected override void Definition()
        {
            base.Definition();
            UIFormId = ValueInput<UIFormId>(nameof(UIFormId), UI.UIFormId.Undefined);
            Requirement(UIFormId, Input);
        }

        protected override ControlOutput In(Flow flow)
        {
            UI.UIFormId formId = flow.GetValue<UI.UIFormId>(UIFormId);
            Target?.CloseUIForm(formId);
            return base.In(flow);
        }
    }
}